<?php
/**
 * User: @lose
 * Date: 2021/1/25
 * Time: 4:42 下午
 */

namespace Frieza\Modules\Photo\Controllers;

use App\Pockets\GridDataModel as pGridDataModel;
use Doraemon\model\AdmNoteOutlineLog;
use Doraemon\service\ABTest\AdminAbTest as sAdminAbTest;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Illuminate\Http\Request;

class PhotoAuditLogController
{
    public function index(Content $content, Request $request)
    {
        $noteId = $request->input('id', '');
        $page = $request->input('page', 1);
        $pageSize = $request->input('per_page', 15);
        $limit = [($page - 1) * $pageSize, $pageSize];

        $list = AdmNoteOutlineLog::getList($noteId, $limit);
        $where = [];
        if($noteId) {
            $where = ['note_id' => $noteId];
        }
        $total = AdmNoteOutlineLog::count($where);

        $gridModel = new pGridDataModel($list, $total);

        $grid = Admin::grid($gridModel, function (Grid $grid) {
            $grid->column('note_id');
            $grid->column('log', '审核日志');

            $grid->actions(function (Grid\Displayers\Actions $actions) {
                $actions->disableDelete();
                $actions->disableEdit();
            });
            $grid->disableCreateButton();
            $grid->disableExport();
            $grid->disableBatchActions();
        });

        return $content
            ->header('note审核日志')
            ->breadcrumb(['text' => 'note审核日志'])
            ->row($grid);
    }

}